import sim, sim_items, main
from util import *
import random

class RelentlessPrefix(sim_items.Prefix):
    def __init__(self):
        super(RelentlessPrefix, self).__init__(
            "relentless", # name
            "This item is inhabited by the spirit of a man "
            "who died with unfinished business, giving its wearer "
            "a supernatural vigor to complete the task at hand." 
        )

    def initialize(self, wearable):
        if not isinstance(wearable, sim_items.Armor):
            raise ValueError('Tried to apply %r to non-armor item: %r' % (self,
                wearable))
        if 'arms' not in wearable.wearSlots:
            return 
        super(RelentlessPrefix, self).initialize(wearable)
        
        self.staminaBonus = random.randint(40,50)
        self.staminaRegenModBonus = random.randint(10,20)
        self.wearable.bonuses.update({
            'maxStaminaMod': self.wearable.bonuses['maxStaminaMod'] + self.staminaBonus,
            'staminaRegenMod': self.wearable.bonuses['staminaRegenMod'] + self.staminaRegenModBonus,
        })

    def remove(self, wearable):
        super(RelentlessPrefix, self).remove(wearable)
        wearable.bonuses.update({
            'maxStaminaMod': self.wearable.bonuses['maxStaminaMod'] - self.staminaBonus,
            'staminaRegenMod': self.wearable.bonuses['staminaRegenMod'] - self.staminaRegenModBonus,
        })

#========================================
thingClass = RelentlessPrefix
